using System;
using System.Collections.Generic;
using System.Text;

namespace uk.co.tonyditchfield.tort.persistence
{
    public interface IDBTransactionScope : IDisposable
    {
        /// <summary>
        /// Persists Object to database
        /// </summary>
        /// <param name="obj">The object to persist</param>
        /// <returns>The same object with additional identity (where appropriate)</returns>
        /// <exception cref="PersistenceException"></exception>
        object Save(object value);

        /// <summary>
        /// Persists Objects to database
        /// </summary>
        /// <param name="obj">The object to persist</param>
        /// <param name="identity">the objects database identity</param>
        /// <returns>rows affected</returns>
        int Save(object value, out object identity);

        object Update(object value);
        int Update(ICollection<object> objectCollection);

        object Delete(object value);
        int Delete(ICollection<object> objectCollection);

        /// <summary>
        /// Loads objects by primary key
        /// </summary>
        /// <param name="objectToRetrieve"></param>
        /// <param name="primeKey"></param>
        /// <returns>The object loaded</returns>
        /// <exception cref="PersistenceException"></exception>
        object LoadByPK(Type objectToRetrieve, object primeKey);

        object LoadByQuery(string query);
        ICollection<object> LoadCollection(string query);

        void Rollback();
        void Complete();
    }
}
